package com.bjb.vr.common.ao;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.bjb.vr.common.utils.DateTimeUtil;
import lombok.Data;
import org.apache.commons.lang.StringUtils;

import java.time.LocalDateTime;
import java.util.Date;
import java.util.Locale;
import java.util.Map;

/**
 * @version 1.0.0
 * @description:
 * @author: caihaibo
 * @createDate: 2022/8/18
 */
@Data
public class ResContentImportAo {

	/**
	 *
	 */
	@TableId(value = "id", type = IdType.AUTO)
	private Long id;

	/**
	 * 内容名
	 */
	@TableField(value = "name")
	private String name;

	/**
	 * 内容版本
	 */
	@TableField(value = "version")
	private String version;

	/**
	 * 预览图片路径
	 */
	@TableField(value = "pre_image_path")
	private String preImagePath;

	/**
	 * web课程详情大图或视频
	 */
	@TableField(value = "show_content_path")
	private String showContentPath;

	/**
	 * 支持设备（如PICO）
	 */
	@TableField(value = "support_devices")
	private String supportDevices;

	/**
	 * 文件类型：image表示全景图，video表示视频，model表示模型，creator表示npt文件;apk,cus_vr 自定义格式
	 */
	@TableField(value = "type")
	private String type;

	/**
	 * 教案名
	 */
	@TableField(value = "case_name")
	private String caseName;

	/**
	 * 教案路径
	 */
	@TableField(value = "case_path")
	private String casePath;

	/**
	 * apk包名
	 */
	@TableField(value = "package_name")
	private String packageName;

	/**
	 * 资源路径
	 */
	@TableField(value = "content_path")
	private String contentPath;

	/**
	 * 资源大小
	 */
	@TableField(value = "content_size")
	private Integer contentSize;

	/**
	 * 资源校验值
	 */
	@TableField(value = "content_check")
	private String contentCheck;

	/**
	 * 排序序号
	 */
	@TableField(value = "priority")
	private Integer priority;

	/**
	 * 资源描述
	 */
	@TableField(value = "description")
	private String description;

	/**
	 * 小节
	 */
	@TableField(value = "sections")
	private String sections;

	/**
	 * 使用次数
	 */
	@TableField(value = "use_count")
	private Integer useCount;

	/**
	 * 关联课程资源厂家ID
	 */
	@TableField(value = "cont_prod_id")
	private Long contProdId;

	/**
	 * 学期（上、下）
	 */
	@TableField(value = "dic_term_code")
	private String dicTermCode;

	/**
	 * 学段
	 */
	@TableField(value = "dic_period_code")
	private String dicPeriodCode;

	/**
	 * 年级
	 */
	@TableField(value = "dic_level_code")
	private String dicLevelCode;

	/**
	 * 学科
	 */
	@TableField(value = "dic_subject_code")
	private String dicSubjectCode;

	/**
	 * 资源类型：交互课件、全景视频、全景图片
	 */
	@TableField(value = "dic_type_code")
	private String dicTypeCode;

	/**
	 * 语言
	 */
	@TableField(value = "dic_type_language")
	private String dicTypeLanguage;

	/**
	 * 课程来源
	 */
	@TableField(value = "dic_source_code")
	private String dicSourceCode;

	/**
	 * 出版社
	 */
	@TableField(value = "dic_type_press")
	private String dicTypePress;

	/**
	 * 备注
	 */
	@TableField(value = "remark")
	private String remark;

	/**
	 * 创建时间
	 */
	@TableField(value = "gmt_create")
	private LocalDateTime gmtCreate;

	/**
	 * 修改时间
	 */
	@TableField(value = "gmt_modified")
	private LocalDateTime gmtModified;

	/**
	 * 主题类型
	 */
	@TableField(value = "dic_theme_code")
	private String dicThemeCode;

	public ResContentImportAo(Object[] args, Map<String,String> dicMap){
		String staticUrl = "";

		String courseId = args[18].toString().trim();

		this.packageName = "com.vlp." + courseId;
		this.casePath = staticUrl + courseId + ".pdf";
		this.preImagePath = staticUrl + courseId + ".png";


		if(args[3].toString().trim().equals("交互课件")){
			this.type = "cus_vr";
			this.showContentPath = staticUrl + courseId + ".mp4";
		}else if(args[3].toString().trim().equals("全景视频")){
			this.type = "video";
			this.showContentPath = staticUrl + courseId + ".mp4";
		}else if(args[3].toString().trim().equals("全景图片")){
			this.type = "cus_vr";
			this.showContentPath = staticUrl + courseId + ".png";
		}
		this.contentPath = staticUrl + courseId + ".zip";

		if(args[0]!=null && StringUtils.isNotBlank(args[0].toString())) {
			this.packageName = "com.vlp." + args[0].toString();
			this.casePath = staticUrl + args[0].toString() + ".pdf";
			this.preImagePath = staticUrl + args[0].toString() + ".png";
			this.showContentPath = staticUrl + args[0].toString() + ".mp4";
			this.type = "cus_vr";
		}else{
			this.casePath = staticUrl + args[18].toString() + ".pdf";
			this.preImagePath = staticUrl + args[18].toString() + ".png";
			this.showContentPath = staticUrl + args[18].toString() + ".mp4";
			this.type = "video";
		}
		this.name = args[1].toString();
		this.caseName = args[1].toString();
		this.dicTypeCode = dicMap.get(args[3].toString());
		this.dicSubjectCode = dicMap.get(args[4].toString());
		this.dicTypePress = dicMap.get(args[5].toString());
		String level = args[6].toString();
		String[] levels = level.split(" ");

		if("通用".equals(levels[0])) {
			this.dicPeriodCode = "1211";
		}else{
			this.dicPeriodCode = dicMap.get(levels[0]);
		}
		if("通用".equals(levels[1])) {
			this.dicLevelCode = "1305";
		}else{
			this.dicLevelCode = dicMap.get(levels[1]);
		}

		this.dicTermCode = dicMap.get(levels[2]);
		this.dicTypeLanguage = dicMap.get(args[7].toString());
		this.supportDevices = dicMap.get(args[9].toString());
		this.description = args[12].toString();
		this.dicSourceCode = dicMap.get(args[14].toString());
//		if(args[15]!=null) {
//			String videoName = args[15].toString();
//			if (!StringUtils.isEmpty(videoName.trim())) {
//				this.contentPath = staticUrl + videoName + ".mp4";
//			} else {
//				this.contentPath = staticUrl + args[0].toString() + ".zip";
//			}
//		}else{
//			this.contentPath = staticUrl + args[0].toString() + ".zip";
//		}
		this.sections = args[17].toString();
		this.gmtCreate = DateTimeUtil.getLocalDateTime(new Date());
		this.dicThemeCode = dicMap.get(args[16].toString());
//		this.casePath = staticUrl + args[0].toString() + ".pdf";
//		this.preImagePath = staticUrl + args[0].toString() + ".png";
//		this.showContentPath = staticUrl + args[0].toString() + ".mp4";

	}

}
